import { http } from '@/utils/request'

// 商品相关接口
export const goodsApi = {
  // 获取商品列表
  getList: (params) => {
    return http.get('/product/getProductList', params)
  },

  // 获取商品详情
  getDetail: (id) => {
    return http.get(`/product/${id}`)
  },

  // 新增商品
  add: (data) => {
    return http.post('/product/createProduct', data)
  },

  // 更新商品
  update: (id, data) => {
    return http.put(`/product/${id}`, data)
  },

  // 删除商品
  delete: (id) => {
    return http.delete(`/product/${id}`)
  },

  // 批量删除商品
  batchDelete: (ids) => {
    return http.delete('/product/batch', { ids })
  },

  // 商品进货
  purchase: (data, id) => {
    return http.post(`/product/${id}/purchase`, data)
  },

  // 商品销售
  sell: (data, id) => {
    return http.post(`/product/${id}/sell`, data)
  },

  // 获取商品库存记录
  getStockRecord: (params) => {
    return http.get('/product/stock/record', params)
  },

  // 获取分类列表
  getCategories: () => {
    return http.get('/product/categories')
  }
}